//
//  MagazineContentCell.m
//  ZYYD-Iphone
//
//  Created by yuzhou on 12-9-19.
//  Copyright (c) 2012年 yuzhou. All rights reserved.
//

#import "MagazineContentCell.h"

@implementation MagazineContentCell
@synthesize titleLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.frame = CGRectMake(0, 0, 320, 44);
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(20, 0, 280, 44)] autorelease];
        label.backgroundColor = [UIColor clearColor];
        label.numberOfLines = 0;
        label.lineBreakMode = NSLineBreakByWordWrapping;
        label.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        label.textColor = [UIColor blackColor];
        label.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:label];
        self.titleLabel = label;
        
        indicatorImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 5, 44)] autorelease];
        indicatorImageView.image = [UIImage imageNamed:@"licurrent.png"];
        indicatorImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        [self.contentView addSubview:indicatorImageView];
        
        bookmarkImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(300, 12, 10, 15)] autorelease];
        bookmarkImageView.image = [UIImage imageNamed:@"bookmark.png"];
        [self.contentView addSubview:bookmarkImageView];
    }
    return self;
}

- (void)adjust
{
    titleLabel.center = CGPointMake(titleLabel.center.x, self.bounds.size.height*0.5);
    CGRect rect = indicatorImageView.frame;
    rect.size.height = self.bounds.size.height;
    indicatorImageView.frame = rect;
}

- (void)setIsBookmark:(BOOL)isBookmark
{
    if (isBookmark) {
        bookmarkImageView.hidden = NO;
    }
    else {
        bookmarkImageView.hidden = YES;
    }
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
//    indicatorImageView.bounds = CGRectMake(0, 0, 5, titleLabel.bounds.size.height + 16);
    if (highlighted) {
        indicatorImageView.hidden = NO;
    }
    else {
        indicatorImageView.hidden = YES;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc
{
    [titleLabel release];
    [super dealloc];
}

@end
